<%-- 
    Document   : busqueda
    Created on : Jan 21, 2013, 10:20:55 PM
    Author     : pcsijbug
--%>

<%@page import="beans.BeanArancel"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script>
            
            function buscar(){
                
                var context = "<%= request.getContextPath() %>";
                
                document.form1.action = context+"/buscarArancel";
                    document.form1.method="POST";
                    document.form1.submit();
                
            }
            
            function agregar(){
                
                var context = "<%= request.getContextPath() %>";
                
                document.form1.action = context+"/agregarProforma";
                    document.form1.method="POST";
                    document.form1.submit();
                
            }
            
            
            function seleccionarArancel(nombreComponente){
                
                var algo = document.getElementById(nombreComponente);
                
                if (algo.checked){
                    
                    algo.value = "1";
                    
                }else{
                   
                    algo.value = "0";
                }
                
               
                
            }
            
        </script>
    </head>
    <body>
<div id="contenido">
  <div align="center">
  <form id="form1" name="form1" method="post" action="">
  
    <table width="403" border="1">
      <tr>
        <td width="121">Codigo/Descripcion</td>
        <td width="144"><label>
          <input type="text" name="txtBuscar" />
        </label></td>
        <td width="54"><label>
                <input type="button" name="Submit" value="Buscar" onclick="javascript:buscar()"/>
        </label></td>
        <td width="56"><input type="button" name="Submit2" value="Agregar" onclick="javascript:agregar()" /></td>
		<td width="56"><input type="submit" name="Submit3" value="Cancelar" /></td>
      </tr>
      
    </table>
  
 
<div id="respuesta">

  <table width="200" border="1">
    <tr>
      <td>Seleccion</td>
      <td>Codigo</td>
      <td>Descripcion</td>
      <td>Precio Unitario </td>
    </tr>

    <% 
    
    if (request.getAttribute("listaAranceles")!=null){
    
    List lista = (List)request.getAttribute("listaAranceles"); 
    
       for (int i = 0; i<lista.size();i++){
           
           BeanArancel ara =  (BeanArancel)lista.get(i);
    %>
    
    <tr>
      <td>
        <label>
            <input type="checkbox" id="checkbox<%= i %>" name="checkbox<%= i %>" value="000" onclick="javascript:seleccionarArancel('checkbox<%= i %>')" />
          </label>
      
      </td>
      <td><%= ara.getCodigoArancel() %></td>
    <input type="hidden" name="hCodArancel<%= i %>" value="<%= ara.getCodigoArancel() %>" />
      <td><%= ara.getDescripcion() %></td>
      <input type="hidden" name="hDescripcion<%= i %>" value="<%= ara.getDescripcion() %>" />
      <td><%= ara.getPrecioUnitario() %></td>
      <input type="hidden" name="hprecioUnitario<%= i %>" value="<%= ara.getPrecioUnitario() %>" />
    </tr>
    <%} %>
    <input type="hidden" name="totalListaRecuperada" value="<%=request.getAttribute("totalArancelesConsulta") %>"
    <input type="hidden" name="totalListaRecuperadaHugo" value="<%= lista.size() %>"

<% } %>
  </table>
  </div>
  </form>
</div>
 </div>

</body>
</html>
